import time

class assume_true_failed :
    def __str__ ( self ) :
        return ''

class assume_false_failed :
    def __str__ ( self ) :
        return ''

class assume_equal_failed :
    def __str__ ( self ) :
        return ''

class assume_not_equal_failed :
    def __str__ ( self ) :
        return ''

class assume_equal_len_failed :
    def __str__ ( self ) :
        return ''

class assume_not_equal_len_failed :
    def __str__ ( self ) :
        return ''

class assume_empty_failed :
    def __str__ ( self ) :
        return ''

class assume_not_empty_failed :
    def __str__ ( self ) :
        return ''

class assume_is_str_failed :
    def __str__ ( self ) :
        return ''

class testing_environment :
    def __init__ ( self ) :
        self . _assumptions = 0
    def get_assumptions ( self ) :
        return self . _assumptions
    def assume_true ( self , a ) :
        self . _assumptions += 1
        if a != True :
            raise assume_true_failed ( )
    def assume_false ( self , a ) :
        self . _assumptions += 1
        if a != False :
            raise assume_false_failed ( )
    def assume_equal ( self , a , b ) :
        self . _assumptions += 1
        if a != b :
            raise assume_equal_failed ( )
    def assume_not_equal ( self , a , b ) :
        self . _assumptions += 1
        if a == b :
            raise assume_not_equal_failed ( )
    def assume_equal_len ( self , container , length ) :
        self . _assumptions += 1
        if len ( container ) != length :
            raise assume_equal_len_failed ( )
    def assume_not_equal_len ( self , container , length ) :
        self . _assumptions += 1
        if len ( container ) == length :
            raise assume_not_equal_len_failed ( )
    def assume_empty ( self , container ) :
        self . _assumptions += 1
        if len ( container ) != 0 :
            raise assume_empty_failed ( )
    def assume_not_empty ( self , container ) :
        self . _assumptions += 1
        if len ( container ) == 0 :
            raise assume_not_empty_failed ( )
    def assume_is_str ( self , s ) :
        self . _assumptions += 1
        if type ( s ) != type ( str ( ) ) :
            raise assume_is_str_failed ( )

class test_suite :
    def __init__ ( self , suite_class ) :
        self . _suite_class = suite_class
    def run ( self ) :
        self . _time = time . time ( )
        env = testing_environment ( )
        for attr in dir ( self . _suite_class ) :
            if attr . startswith ( 'test_' ) :
                suite = self . _suite_class ( env )
                getattr ( suite , attr ) ( )
                del suite
        self . _time = time . time ( ) - self . _time
        self . _assumptions = env . get_assumptions ( )
    def get_title ( self ) :
        return self . _suite_class . __doc__
    def get_time ( self ) :
        return self . _time
    def get_assumptions ( self ) :
        return self . _assumptions
